<?php

include_once 'model/model.php';
/**
 *
 * Our Controller class has only one function and the constructor.
 * The constructor instantiate a model class and when a request is done,
 * the controller decide which data is required from the model.
 * Then it calls the model class to retrieve the data.
 * After that it calls the corresponding passing the data coming from the model.
 * The code is extremely simple. Note that the controller does not know anything about
 * the database or about how the page is generated.
 * @author JAdriano.Teixeira
 *
 */
class Controller {

	public $model;


	public function __construct() {
		$this->model = new Model();
	}

	public function index() {
		include 'view/main.php';
	}


	public function invoke() {
		if (!isset($_GET['book'])) {
			// no book requested
			$books = $this->model->getBookList();
			include 'view/booklist.php';
		}
		else {							// specific request
			$book = $this->model->getBook($_GET['book']);
			include 'view/viewbook.php';
		}
	}
}

?>